<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>当前用户</title>
    <link href="https://cdn.staticfile.org/layui/2.6.4/css/layui.min.css">
    <script src="https://cdn.staticfile.org/layui/2.6.4/layui.min.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js"></script>

</head>
<body>
<h1 th:text="${userInfo.username}">当前用户登录账号</h1>

<button onclick="addUser()">添加用户</button>

<h2>当前租户用户数:[[${usercount}]]</h2>

<h2><a href="/logout">退出当前系统</a></h2>

<script>
    //修改系统名称
    function addUser(){
        var content='<div class="layui-form-item" style="margin-right:35px">';
        content+='<label class="layui-form-label">用户账号:</label>';
        content+='  <div class="layui-input-block">';
        content+='    <input type="text" value="" name="username"  class="layui-input">';
        content+='  </div>';
        content+='</div>';

        /*content+='<div class="layui-form-item" style="margin-right:35px">';
        content+='  <label class="layui-form-label">验证码:</label>';
        content+='  <div class="layui-input-block">';
        content+='    <input type="text" value="" name="veryCode" style="width:50%;" class="layui-input layui-col-xs5" >';
        content+='<img class="layui-col-xs5" style="height:37px;" src="/authenticationCode.jsp?'+Math.random()+'" onclick="this.src=\'/authenticationCode.jsp?\'+Math.random()" height="30">';
        content+='  </div>';
        content+='</div>';*/

        layer.open({
            type: 1 //Page层类型
            ,area: ['280px', '200px']
            ,btn:["确定","取消"]
            ,title: '添加用户'
            ,skin: 'layui-layer-prompt'
            ,content: content
            ,yes: function(index, layero){
                //按钮【按钮一】的回调
                //var reg =/^[0-9]*$/;
                var username=$(layero).find("input[name='username']").val();
                if(username==""){
                    layer.msg("用户账号不能为空");
                    return;
                }
                $.ajaxSettings.async = false;//设置方法同步
                $.post("/addUser",{
                    username:username
                },function(data,status){
                    if(data.success){
                        location.reload();
                        layer.close(index);
                    }else{
                        layer.msg(data.msg);
                    }
                });
            }
        });
    }
</script>
</body>
</html>